import { Layout } from 'antd'
import { NavLink, getLocale, setLocale,useIntl } from 'umi'
import { Menu, Dropdown, Popover, Badge, Select ,Spin} from 'antd';
import { BellOutlined, DownOutlined } from '@ant-design/icons'
import useStore from '@/context/useStore';
// import { NavLink, getLocale, setLocale, useIntl } from 'umi'
// import { Menu, Dropdown, Popover, Badge, Select } from 'antd';
// import { BellOutlined ,DownOutlined} from '@ant-design/icons'
import './teachersLayout.less'
import { useEffect, useState } from 'react';
import { getInfo1 } from '@/services';
import { Iusers } from '@/utils/interface';
import { timeAgo } from '@/utils';
import {removeCookie} from '@/utils/auth'

const { Header, Footer, Content } = Layout
const practiceMenu = <Menu>
    <Menu.Item>
        <NavLink to='/teachers/planList' onClick={() => window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '导航菜单', '计划'])}>计划</NavLink>
    </Menu.Item>
    <Menu.Item>
        <NavLink to='/teachers/viewPlan' onClick={() => window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '导航菜单', '进度'])}>进度</NavLink>
    </Menu.Item>
    <Menu.Item>
        <NavLink to='/teachers/defence' onClick={() => window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '导航菜单', '答辩'])}>答辩</NavLink>
    </Menu.Item>
</Menu>
const interviewList = <Menu>
    <Menu.Item>
        <NavLink to='/teachers/interviewList' onClick={() => window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '导航菜单', '面试记录'])}>面试记录</NavLink>
    </Menu.Item>
    <Menu.Item>
        <NavLink to='/teachers/interviewManage' onClick={() => window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '导航菜单', '面试记录管理'])}>面试记录管理</NavLink>
    </Menu.Item>
    <Menu.Item>
        <NavLink to='/teachers/rankList' onClick={() => window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '导航菜单', '面试排行榜'])}>面试排行榜</NavLink>
    </Menu.Item>
</Menu>
const questionMenu = <Menu>
    <Menu.Item>
        <NavLink to='/teachers/questionDetail' onClick={() => window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '导航菜单', '回答列表'])}>问答列表</NavLink>
    </Menu.Item>
    <Menu.Item>
        <NavLink to='/teachers/questionHandle' onClick={() => window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '导航菜单', '回答管理'])}>问答管理</NavLink>
    </Menu.Item>
</Menu>
const teacherPersonCenter = <Menu>
    <Menu.Item>
        <NavLink to="/teachers/teacherPersonCenter">个人中心</NavLink>
    </Menu.Item>
    <Menu.Item>
        <NavLink to="/teachers/needHandle">代办管理</NavLink>
    </Menu.Item>
    <Menu.Item>
        <NavLink to="/login">退出</NavLink>
    </Menu.Item>
</Menu>
const content = (
    <div>
        <p>Content</p>
        <p>Content</p>
    </div>
);

const enLanguage: { [key: string]: string } = {
    'en': 'en-US',
    'en-US': 'en-US',
}

const TearcherLayout: React.FC = (props) => {
    const [users, setusers] = useState<Iusers>({} as Iusers)
    const { global } = useStore();
    const intl = useIntl();
    
    useEffect(() => {
        getInfo1().then(res => {
            if (res.code === 200) {
                console.log(res.code)
                setusers({ ...res.user })
            }
        })

        let language = navigator.language;
        if (language) {
            setLocale(enLanguage[language], false);
        }
    }, [])

    const start = '2021-10-30 10:00';
    const end = '2021-10-30 13:00';
    console.log(timeAgo(+new Date(end) - +new Date(start)));

    return <Layout>
       
            <Header>
                <img src="http://111.203.59.61:8060/static/img/w_bw.172a76e5.png" alt="" />
                <div>
                    <NavLink to='/teachers/postskill'>岗位</NavLink>
                    <NavLink to='/teachers/proManagemen'>项目</NavLink>
                    <Dropdown overlay={practiceMenu}><span>实训<DownOutlined /></span></Dropdown>
                    <Dropdown overlay={interviewList}><span>面试<DownOutlined /></span></Dropdown>
                    <Dropdown overlay={questionMenu}><span>问答<DownOutlined /></span></Dropdown>
                    <Select className='ant-select' value={getLocale()} onChange={value => {
                        setLocale(value, false)
                        window._hmt.push(['_trackEvent', 'tearcherLayout', 'click', '国际化', value])
                    }}>
                        <Select.Option value="en-US">English</Select.Option>
                        <Select.Option value="zh-CN">中文</Select.Option>
                        <Select.Option value="ko-KR">한국어</Select.Option>
                    </Select>
                </div>
                <Popover placement="topLeft" content={content}>
                    <Badge count={5}>
                        <BellOutlined />
                    </Badge>
                </Popover>
                <span>
                    <Dropdown overlay={teacherPersonCenter}><img id='img' src={'http://111.203.59.61:8060' + users.avatar} alt="" /></Dropdown>
                    <span className='span'>{users.nickName}</span>
                </span>
            </Header>
            <Content>{props.children}</Content>
            <Footer>
                <div className="bw_bottom">
                    <div className="b_b_detail">
                        <div className="b_b_left">
                            <div className="bw_img">
                                <img src="http://111.203.59.61:8060/static/img/bottom_logo.c8aa9859.png" alt="" />
                            </div>
                            <div className="b_w_tel">400-008-0987</div></div>
                        <div className="b_b_middle">
                            <div className="middle_one middle">
                                <div className="middle_title">走进八维</div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/about.html">集团概况</a>
                                </div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/news/index.html">八维动态</a>
                                </div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/lead.html">领导关怀</a>
                                </div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/honour.html">企业荣誉</a>
                                </div>
                            </div>
                            <div className="middle_two middle">
                                <div className="middle_title">八维文化</div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/culture.html">八维理念</a>
                                </div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/spirit.html">八维精神</a>
                                </div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/dak.html">文化驿站</a>
                                </div></div><div className="middle_three middle">
                                <div className="middle_title">社会责任</div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/duty/public.html">社会公益</a>
                                </div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/duty/great.html">大善之举</a>
                                </div>
                            </div>
                            <div className="middle_four middle">
                                <div className="middle_title">联系我们</div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/partners.html">业务合作</a>
                                </div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/sign_up.html">咨询报名</a>
                                </div>
                                <div className="href_a">
                                    <a href="http://bwie.cn/bwie/concact.html">联系方式</a>
                                </div>
                            </div>
                        </div>
                        <div className="b_b_right">
                            <img src="http://111.203.59.61:8060/static/img/wechat.e60a83ec.png" alt="" />
                            <div className="wechat_text">八维微信公众号</div>
                        </div>
                    </div>
                    <div className="b_b_sign">京公网安备 11010802031438号 © Copyright 2020. 八维教育版权所有 | 京ICP备12008262号-12</div>
                </div>
            </Footer>
       
    </Layout>
}

export default TearcherLayout